// 物流首页
var baseExp = require('../../../common/BaseExpress');
var baseList = require('../../../common/BaseList');
Page({
  behaviors: [baseExp,baseList],
  data: {

    //模拟数据userInfo
    userInfo: {
      nickname: '莫奈的猫',
      uid: '123456789'
    },
    tabList:[
      {title:'未处理',name:1},
      {title:'已处理',name:2}
    ],
    active:1,
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
    let menuButtonObject = wx.getMenuButtonBoundingClientRect();
    this.setData({
      navTop: menuButtonObject.top,
      navHeight: menuButtonObject.bottom + 5,
      titleHeight: menuButtonObject.bottom - menuButtonObject.top,
    });
  },
  navBack() {
    wx.navigateBack()
  },
  look_click(e){
    wx.navigateTo({
      url: '/pages/cls/staff/Detail?shelve_num='+e.currentTarget.dataset.shelve_num+"&day="+e.currentTarget.dataset.day,
    })
  },
  toExpressDetail(e) {
    wx.navigateTo({
      url: "/pages/mina/expressDetail/expressDetail?shelve_num="+e.currentTarget.dataset.shelve_num+"&day="+e.currentTarget.dataset.day,
    })
  },

  tab_change(e) {
    // console.log("e",e);
    // console.log(this.data.active);
    // this.data.active=e.detail.name;
    this.setData({
      active:e.detail.name,
      [`reqData.so`]:''
    })
    this.data.current_page=0;
    this.data.reqUrl="/home/staff/order?type="+this.data.active;
    this.req_items();
  },
  search_click(e){
    console.log("确认搜索",e);
    this.data.reqData.so=e.detail;
    this.data.current_page=0;
    this.data.reqUrl="/home/staff/order?type="+this.data.active;
    this.req_items();
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let authToken = wx.getStorageSync('authToken');
    if(!authToken){
      wx.redirectTo({
        url: '/pages/cls/staff/Login',
      })
      return ;
    }
    
    this.request({
      url:this.data.host+ '/home/staff/detail',
      loadingTip:'加载中',
    },res=>{
      console.log(res);
      let userInfo=res.data;
      userInfo.thumb=this.get_face(userInfo.face);
      this.setData({
        userInfo
      })
    });
    //
    this.req_orders();
  },

  req_orders(){

    this.data.current_page=0;
    this.data.reqUrl="/home/staff/order?type="+this.data.active;
    this.req_items();
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },


  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})